{extend name="public/base"/}
{block name="style"}
<link href="__PUBLIC__/ieasy/css/recently.css?v=2.1.49" rel="stylesheet" type="text/css">
<link href="__PUBLIC__/ieasy/css/classify.css?v=2.1.49" rel="stylesheet" type="text/css">
{/block}
{block name="body"}
<div id="console_main"></div>
<div class="head_tit_box">
	<a href="javascript:;" class="head_return_page_but"></a>
		<div class="head_menu_but_box">
		<a href="javascript:;" class="head_menu_but"></a>
	</div>
		<h1>限免专区</h1>
</div>
<!--导航-->
{block name="include"}{include file="public:dropnav" /}{/block}
<div class="body_sytle">
	<div class="c_list_box">
		<ul class="r_img_ul">
		</ul>
		<div class="loading_box"><span>正在加载中，请稍后......</span></div> 
		<!--r_img_ul 列表 r_img_remove_select-->
	</div>
	
	<div class="content_null_box" style="display: none; padding-top: 1rem;">
		<img src="__PUBLIC__/ieasy/img/icon_16.png?v=2.1.49" style="width: 1.28rem;" />
		<span>暂无限免小说</span>
		<div class="content_null_but_box">
			<a href="/">去首页看看</a>
		</div>
	</div>
</div>

{/block}
{block name="script"}
<script type="text/javascript" src="__PUBLIC__/ieasy/js/zepto.min.js?v=2.1.49"></script>
<script type="text/javascript" src="__PUBLIC__/ieasy/js/zepto.cookie.min.js?v=2.1.49"></script>

<!-- 这是zepto插件 -->

<script type="text/javascript" src="__PUBLIC__/ieasy/js/common.js?v=2.1.49"></script>
<script type="text/javascript" src="__PUBLIC__/ieasy/js/cps_log.js?v=2.1.49"></script>
<script type="text/javascript">
	var sBookstop=true,sBookstopTime=null;
	var start=0, 
	limit=10,
	sBookstop=true, 
	sBookstopTime=null, 
	pagesize=10;

	$(function(){
		loadingList();
		
		$(window).scroll(function(){
			var nWinH =  document.documentElement.clientHeight;
			var nScrollTop = (document.body.scrollTop || document.documentElement.scrollTop) + nWinH;
			var nBodyScrollH = document.body.scrollHeight;
			if(sBookstop && nBodyScrollH - nScrollTop < 240){
				bookstoptime();
				$('.loading_box').html('<span>正在加載中，请稍候......</span>').show();
				loadingList();
			}
		});
	});


	function loadingList(){
		$.ajax({
			type: 'get',
			url: '/api/index/getfree/',
			timeout: 10000,
			cache: false,
			dataType: 'json',
			data: {
				'start': start,
				'limit': limit,
			},
			success: function (data) {
				clearTimeout(sBookstopTime);
				if (typeof data == 'string') {
					data = JSON.parse(data);
				}
				if(data.code==2){
				   $('.c_list_box,.loading_box').hide();
				   $('.content_null_box').show();
					return false;
				}
				var sLi = '';
				for(var i=0; i<data.length; i++){

						sLi += '<li>\
							<a href="/book/info/id/'+ data[i]['id'] +'.html">\
								<div class="r_img">\
									<img src="'+ data[i]['cover'] +'" data-original="'+ data[i]['cover'] +'" />\
									<strong>限免</strong>\
								</div>\
								<div class="r_img_text">\
									<h3>'+ data[i]['title'] +'</h3>\
									<p>'+ data[i]['intro'] +'</p>\
									<div class="r_img_other"><b>限时免费：'+ data[i]['startdate']+'-'+ data[i]['enddate']+'</b></div>\
								</div>\
							</a>\
						</li>';
		
					
				}
				$('.r_img_ul').append(sLi);
				start+=pagesize;
				/*
				if(data.length < pagesize){
					$('.loading_box').html('<span>已显示全部</span>').show();
					sBookstop = false;
				}else{
					$('.loading_box').html('<span>下拉加载更多</span>').show();
					sBookstop = true;
				}	
				*/
				$('.loading_box').html('<span>已显示全部</span>').show();
					sBookstop = false;
				$('img').picLazyLoad({
					effect : "fadeIn"
				});

			},
			error: function (XMLHttpRequest, textStatus, errorThrown) {
				$('.loading_box').html('<span>已显示全部</span>').show();
					sBookstop = false;
				$('img').picLazyLoad({
					effect : "fadeIn"
				});
			}
		});
	}



	//防止重复请求数据
	function bookstoptime() {
		clearTimeout(sBookstopTime);
		sBookstop = false;
		sBookstopTime = setTimeout(function () {
			sBookstop = true;
		}, 10000);
	}

</script>
{/block}